from fastapi import APIRouter, Depends, Security
from fastapi.security import HTTPAuthorizationCredentials

from app.repository.auth_repo import JWTBearer, JWTRepo
from app.schema import ResponseSchema

router = APIRouter(prefix="/token", tags=["token"], dependencies=[Depends(JWTBearer())])


@router.post("/refresh", response_model=ResponseSchema, response_model_exclude_none=True)
async def get_token_refresh(
        credentials: HTTPAuthorizationCredentials = Security(JWTBearer()),
):
    if JWTBearer.verify_jwt(credentials):
        result = JWTRepo(token=credentials).update_token()
        # result = JWTRepo(token=result).decode_token()
    return ResponseSchema(detail="success", result=result)

# @router.post("/update-profile/")
# async def update_user_profile(credentials: HTTPAuthorizationCredentials = Security(JWTBearer())):

#     # await AuthService.update_profile_service(data)
#     return ResponseSchema(detail="Successfully update data!")
